package GUI;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.ComponentOrientation;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Image;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Vector;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
import javax.print.attribute.HashPrintRequestAttributeSet;
import javax.print.attribute.PrintRequestAttributeSet;
import javax.print.attribute.standard.Copies;
import javax.print.attribute.standard.MediaPrintableArea;
import javax.print.attribute.standard.MediaSize;
import javax.print.attribute.standard.MediaSizeName;
import javax.swing.AbstractButton;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.border.EmptyBorder;
import javax.swing.border.LineBorder;
import javax.swing.border.TitledBorder;

//import org.jdesktop.animation.timing.Animator;
//import org.jdesktop.animation.timing.interpolation.PropertySetter;

import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExporterParameter;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
import net.sf.jasperreports.engine.export.JRPrintServiceExporter;
import net.sf.jasperreports.engine.export.JRPrintServiceExporterParameter;
import net.sf.jasperreports.engine.util.JRLoader;
import net.sf.jasperreports.view.JasperViewer;
import CommonGui.ChkObj;
import CommonGui.ChkRender;
import DataObjects.Bon;
import DataObjects.FireForManageTableOrder;
import DataObjects.ForBonList;
import DataObjects.Menu;
import DataObjects.MenuForFire;
import DataObjects.MetaDataOrder;
import DataObjects.Recipe;
import DataObjects.RecipeForFire;
import Messages.MessageGetAllMenues;
import Messages.MessageGetAllMenuesReply;
import Messages.MessageGetFiresByOrderid;
import Messages.MessageGetFiresByOrderidReply;
import Messages.MessageSaveCommentsForATable;
import Messages.MessageSaveFires;
import Messages.MessageSavingReply;
import Reports.FullBon;
import Reports.MenuesForPrintForFullBon;

public class PfManageTableOrderPanel extends JPanel  implements MouseMotionListener{
	
	private MainMenu mainMenu;
	private JList orderList;
	private Vector<FireForManageTableOrder> vectorFireForManegeTableOrder;
	private Vector<Menu> menues;
	private Vector<Bon> bones;
	private MetaDataOrder metaDataOrder;
	private Dimension screenSize;
	private JTextField commentsText;
	private int x;
	private int y;
	private int xx;
	private int yy;
	private int xxheight;
	private int yywidth;
	private int mousePressedFlag=0;
	private int firstPoint=-1;
	private int secondPoint=-1;

	public PfManageTableOrderPanel(MainMenu mm,String tableNo) 
	{
		super();
		setBackground(new Color(255, 222, 173));
		
		screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		x=screenSize.width;
		y=screenSize.height;
		this.mainMenu=mm;
		
		
		MessageGetAllMenues allMenues=new MessageGetAllMenues(tableNo);
		try {
			mainMenu.ms.client.sendToServer(allMenues);
			MessageGetAllMenuesReply result = (MessageGetAllMenuesReply)mainMenu.ms.client.GetMessage();	
			this.menues=result.getMenues();
			this.bones=result.getBones();
			
			
			this.metaDataOrder=result.getMetaDataOrder();
		}catch (IOException ei) {
			// TODO Auto-generated catch block
			ei.printStackTrace();
		}
		
		
		MessageGetFiresByOrderid allFires=new MessageGetFiresByOrderid(metaDataOrder.getOrderId());
		try {
			mainMenu.ms.client.sendToServer(allFires);
			MessageGetFiresByOrderidReply result = (MessageGetFiresByOrderidReply)mainMenu.ms.client.GetMessage();	
			this.vectorFireForManegeTableOrder=result.getVectorFireForManageTableOrder();
		}catch (IOException ei) {
			// TODO Auto-generated catch block
			ei.printStackTrace();
		}
		
		
			
		this.setLayout(null);
		initialize();
	}
	
	
	
	
	
	private void initialize()
	{
		JLabel tableLabel=new JLabel(" מספר שולחן : "+ metaDataOrder.getTid());
		tableLabel.setBackground(new Color(0, 0, 128));
		tableLabel.setForeground(new Color(0, 0, 128));
		tableLabel.setFont(new Font("Tahoma", Font.BOLD, x/48));
		tableLabel.setBounds(x/10, y/8, x/4, y/13);
		add(tableLabel);
		
		JLabel nameLabel=new JLabel(" מלצר: "+ metaDataOrder.getName());
		nameLabel.setBackground(new Color(0, 0, 128));
		nameLabel.setForeground(new Color(0, 0, 128));
		nameLabel.setFont(new Font("Tahoma", Font.BOLD, x/65));
		nameLabel.setBounds(9*x/53, y/5, x/4, y/13);
		add(nameLabel);
		
		
		JLabel commentsLabel=new JLabel(" הערות מיוחדות: ");
		commentsLabel.setBackground(new Color(0, 0, 128));
		commentsLabel.setForeground(new Color(0, 0, 128));
		commentsLabel.setFont(new Font("Tahoma", Font.BOLD, x/100));
		commentsLabel.setBounds(9*x/53, 10*y/20, x/4, y/13);
		add(commentsLabel);
		
		
		
		commentsText=new JTextField(metaDataOrder.getComments());	
		commentsText.setBackground(new Color(255, 250, 240));
		commentsText.setHorizontalAlignment(JTextField.RIGHT);
		commentsText.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
		commentsText.setFont(new Font("Tahoma", Font.PLAIN, 20));
		commentsText.setBounds(9*x/110, 15*y/27, x/6, y/23);
		commentsText.addMouseListener(new MouseAdapter()                                                  
        {
            public void mouseClicked(MouseEvent e)                                                                      
            {
            	final VKBLettersAndDigitsPopUp vkbPanel=new VKBLettersAndDigitsPopUp(new Color(200,250,230));                                                                 
        		vkbPanel.setBounds(9*x/65, 15*y/60, 6*x/12, 2*y/7);
                Point p = commentsText.getLocationOnScreen();
                Point p2=new Point();
                p2.x=10*x/650;
                p2.y =20*y/50;
                p.x+=x/2;
                vkbPanel.setLocation(p2);
                vkbPanel.setVisible(true);
            }
        });
		if(metaDataOrder.getComments()!=null && !metaDataOrder.getComments().isEmpty())
		{
			add(getCommentsLabel());
		}
		add(commentsText);
		add(getSaveCommnetsButton());
		add(getUpdateOrderButton());
		add(getBackButton());
		add(getBonPrintButton());
		add(getHeshbonPrintButton());
		add(getPaymentButton());
		add(getFireButton());
		add(getChangeAddBillButton());
		add(getCancelTableButton());
		add(getOrderList());
		add(getUpButton());
		add(getDownButton());
		add(getDownToEndButton());
		add(getUpToEndButton());
		
		xx=this.getBounds().x;
		yy=this.getBounds().y;
		xxheight=this.getSize().height;
		yywidth=this.getSize().width;
		
	}
	
		
		private JLabel getCommentsLabel()
		{
			JLabel label=new JLabel(metaDataOrder.getComments());
			label.setBackground(new Color(0, 0, 128));
			label.setForeground(new Color(0, 0, 128));
			label.setFont(new Font("Tahoma", Font.BOLD, x/65));
			label.setBounds(9*x/53, y/4, x/4, y/13);
			
			return label;
		}
	
	
		private JButton getSaveCommnetsButton()
		{
			JButton saveCommentsButt=new JButton("הוסף הערה");
			saveCommentsButt.setFont(new Font("Tahoma", Font.BOLD, x/120));
			saveCommentsButt.setBounds(9*x/650, 15*y/27, x/15, y/23);			
			saveCommentsButt.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) 
				{
					
					metaDataOrder.setComments(commentsText.getText());
					MessageSaveCommentsForATable msg=new MessageSaveCommentsForATable(metaDataOrder);
					try {
						mainMenu.ms.client.sendToServer(msg);
						MessageSavingReply result = (MessageSavingReply)mainMenu.ms.client.GetMessage();
						if(result.getResult()==1)
						{
						//JOptionPane.showMessageDialog(null,"הנתונים נשמרו בהצלחה");	
						mainMenu.getContentPane().validate();
						mainMenu.getContentPane().repaint();
						}
						else
						JOptionPane.showMessageDialog(null,"בעיית תקשורת 192");

					} catch (IOException ei) {
						// TODO Auto-generated catch block
						ei.printStackTrace();
					}
					

				}
			});
			
			
			
			return saveCommentsButt;
		}
	
		private JButton getFireButton()
		{
			Icon fireIcon = new ImageIcon("fire-icon.png");
			Image img = ((ImageIcon) fireIcon).getImage();
			Image newimg = img.getScaledInstance(40, 40,java.awt.Image.SCALE_SMOOTH);
			fireIcon = new ImageIcon(newimg);
			JButton fireButt=new JButton("FIRE",fireIcon);
			fireButt.setBackground(new Color(255, 127, 80));
			fireButt.setVerticalTextPosition(AbstractButton.BOTTOM);
			fireButt.setHorizontalTextPosition(AbstractButton.CENTER);
			fireButt.setFont(new Font("Tahoma", Font.BOLD, x/90));
			fireButt.setBounds(9*x/14, 15*y/150, 6*x/45, 2*y/24);
			
			fireButt.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) 
				{
					Vector<FireForManageTableOrder> fires=new Vector<FireForManageTableOrder>();
					for(int i=0;i<orderList.getModel().getSize();i++)
					{
						if(((ChkObj)orderList.getModel().getElementAt(i)).flagSubmitted && ((ChkObj)orderList.getModel().getElementAt(i)).flagFired)
						{
							FireForManageTableOrder fire =new FireForManageTableOrder();
							RecipeForFire recipe = ((ChkObj)orderList.getModel().getElementAt(i)).getRecipeForFire();			
					
							fire.setExtra(recipe.getExtra());
							fire.setComments(recipe.getComments());
							fire.setSouce(recipe.getSouce());
							fire.setFired(true);
							
							fire.setMid(((ChkObj)orderList.getModel().getElementAt(i)).getForBonList().getMenu().getMid());
							fire.setNameOfRecipe(recipe.getName());
							fire.setRid(recipe.getRid());
							fire.setOrderId(Integer.parseInt(metaDataOrder.getOrderId()));
							DateFormat timeFormat = new SimpleDateFormat("HH:mm:ss");
							Date date = new Date();
							String fireTime=timeFormat.format(date);
							fire.setTimeOfFire(fireTime);
							fire.setSubmitted(false);
							fire.setActionLevel(recipe.getActionLevel());
							fire.setQuantity(((ChkObj)orderList.getModel().getElementAt(i)).getQuantity());
							fires.add(fire);
							
						}
						
					}
					
					MessageSaveFires msg=new MessageSaveFires(fires);
					try {
						mainMenu.ms.client.sendToServer(msg);
						MessageSavingReply result = (MessageSavingReply)mainMenu.ms.client.GetMessage();
						if(result.getResult()==1)
						{
						JOptionPane.showMessageDialog(null,"הנתונים נשמרו בהצלחה");	
						mainMenu.getContentPane().remove(((BorderLayout) mainMenu.getContentPane().getLayout()).getLayoutComponent(BorderLayout.CENTER));
						mainMenu.getContentPane().add(new PfManageTableOrderPanel(mainMenu,metaDataOrder.getTid()), BorderLayout.CENTER);
						
						//mainMenu.getContentPane().remove(((BorderLayout) mainMenu.getContentPane().getLayout()).getLayoutComponent(BorderLayout.CENTER));
						}
						else
						JOptionPane.showMessageDialog(null,"בעיית תקשורת 192");

					} catch (IOException ei) {
						// TODO Auto-generated catch block
						ei.printStackTrace();
					}
					
					
				}
			});
			return fireButt;
		}
	
		
		private JButton getUpdateOrderButton()
		{
			Icon addIcon = new ImageIcon("add-icon.png");
			Image img = ((ImageIcon) addIcon).getImage();
			Image newimg = img.getScaledInstance(40, 40,java.awt.Image.SCALE_SMOOTH);
			addIcon = new ImageIcon(newimg);
			JButton updateButt=new JButton("הוספה/עידכון מנה",addIcon);
			updateButt.setBackground(new Color(200,250,230));
			updateButt.setVerticalTextPosition(AbstractButton.BOTTOM);
			updateButt.setHorizontalTextPosition(AbstractButton.CENTER);
			updateButt.setFont(new Font("Tahoma", Font.BOLD, x/90));
			updateButt.setBounds(9*x/11, 15*y/150, 6*x/45, 2*y/24);
			
			updateButt.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) 
				{
					
					mainMenu.getContentPane().remove(((BorderLayout) mainMenu.getContentPane().getLayout()).getLayoutComponent(BorderLayout.CENTER));
					PfUpdateTableOrder update= new PfUpdateTableOrder(mainMenu, menues, bones, metaDataOrder,vectorFireForManegeTableOrder);
					mainMenu.getContentPane().add(update,BorderLayout.CENTER);
					

				}
			});
			return updateButt;
		}
	
	
		
		
		
		private JButton getBackButton()
		{
			Icon backIcon = new ImageIcon("back-icon.png");
			Image img = ((ImageIcon) backIcon).getImage();
			Image newimg = img.getScaledInstance(40, 40,java.awt.Image.SCALE_SMOOTH);
			backIcon = new ImageIcon(newimg);
			JButton backButt=new JButton("לרשימת שולחנות",backIcon);
			backButt.setBackground(new Color(200,250,230));
			backButt.setVerticalTextPosition(AbstractButton.BOTTOM);
			backButt.setHorizontalTextPosition(AbstractButton.CENTER);
			backButt.setFont(new Font("Tahoma", Font.BOLD, x/90));
			backButt.setBounds(9*x/500, 15*y/23, 6*x/45, 2*y/24);
			
			backButt.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) 
				{
					
					
					

				}
			});
			return backButt;
		}
		
	
		private JButton getBonPrintButton()
		{
			Icon bonIcon = new ImageIcon("bon-icon.png");
			Image img = ((ImageIcon) bonIcon).getImage();
			Image newimg = img.getScaledInstance(40, 40,java.awt.Image.SCALE_SMOOTH);
			bonIcon = new ImageIcon(newimg);
			JButton bonButt=new JButton("הדפסת בון",bonIcon);
			bonButt.setBackground(new Color(200,250,230));
			bonButt.setVerticalTextPosition(AbstractButton.BOTTOM);
			bonButt.setHorizontalTextPosition(AbstractButton.CENTER);
			bonButt.setFont(new Font("Tahoma", Font.BOLD, x/90));
			bonButt.setBounds(9*x/11, 15*y/70, 6*x/45, 2*y/24);
			
			bonButt.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) 
				{
					//-----------ANDREY--------------------------------3/4/2013-----------------------------------
					 Date date = new Date();
					 DateFormat df = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
					 String   data = df.format(date);
					 MenuesForPrintForFullBon menues = new MenuesForPrintForFullBon();
					 Vector<MenuesForPrintForFullBon> menuesForPrint = new  Vector<MenuesForPrintForFullBon>();
					 FullBon bonForPrint = new FullBon();
					 ArrayList<FullBon> dataList = new ArrayList<FullBon>();
					 
					 Vector<String> row = new Vector<String>();
					 row.add("rice");
					 row.add("potatos");
					 menues.setMid("3");
					 menues.setmName("טעימות");
					 menues.setRecipesForChoose(row);
					 menuesForPrint.add(menues);
					 
					 bonForPrint.setTid("5");
					 bonForPrint.setName("אנדריי");
					 bonForPrint.setDate(data);
				     bonForPrint.setOrderId("3");
					 dataList.add(bonForPrint);
					

	//----------------probuem srazu pechatat----------------------------------------
						
						try {
						
							JRBeanCollectionDataSource reportData = new JRBeanCollectionDataSource(
									dataList);
							JasperPrint print;
							
								print = JasperFillManager
										.fillReport(
												"Reports/Orders/test.jasper",
												null, reportData);
						
						PrinterJob job = PrinterJob.getPrinterJob();
					    PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null);
					    int selectedService = 0;
						
					 // vibiraem printer s nazvaniem Brother
					    
					    for(int i = 0; i < services.length;i++){
					      if(services[i].getName().contains("Brother")){
					        selectedService = i;
					      }
					    }


					    // Gotovim printer
					    try {
							job.setPrintService(services[selectedService]);
						} catch (PrinterException e1) {
							// TODO Auto-generated catch block
							e1.printStackTrace();
						}
					    PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();
					    MediaSizeName mediaSizeName = MediaSize.findMedia(4, 4, MediaPrintableArea.INCH);
					    printRequestAttributeSet.add(mediaSizeName);
					    printRequestAttributeSet.add(new Copies(1));

					    // Posilaem
					    JRPrintServiceExporter exporter;
					    exporter = new JRPrintServiceExporter();
					    exporter.setParameter(JRExporterParameter.JASPER_PRINT, print);
					    exporter.setParameter(JRPrintServiceExporterParameter.PRINT_SERVICE,
					        services[selectedService]);
					    exporter.setParameter(JRPrintServiceExporterParameter.PRINT_SERVICE_ATTRIBUTE_SET,
					        services[selectedService].getAttributes());
					    exporter.setParameter(JRPrintServiceExporterParameter.PRINT_REQUEST_ATTRIBUTE_SET,
					        printRequestAttributeSet);
					    exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG,
					        Boolean.FALSE);
					    exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG,
					        Boolean.FALSE);
					    exporter.exportReport();
				}
					    catch (JRException e1) {
							// TODO Auto-generated catch block
							e1.printStackTrace();
						}

				}
			});
			return bonButt;
		}
		
		private JButton getChangeAddBillButton()
		{
			Icon paymentIcon1 = new ImageIcon("cash.png");
			Image img1 = ((ImageIcon) paymentIcon1).getImage();
			Image newimg1 = img1.getScaledInstance(50, 40,java.awt.Image.SCALE_SMOOTH);
			paymentIcon1 = new ImageIcon(newimg1);
			JButton billButt=new JButton("הוספה/עדכון חשבון",paymentIcon1);
			billButt.setBackground(new Color(200,250,230));
			billButt.setFont(new Font("Tahoma", Font.BOLD, x/90));
			billButt.setVerticalTextPosition(AbstractButton.BOTTOM);
			billButt.setHorizontalTextPosition(AbstractButton.CENTER);
			billButt.setBounds(9*x/11, y/3, 6*x/45, 2*y/20);
			return billButt;
		}
		
		
		private JButton getCancelTableButton()
		{
			JButton cancButt=new JButton("ביטול שולחן");
			cancButt.setBackground(new Color(200,250,230));
			cancButt.setVerticalTextPosition(AbstractButton.BOTTOM);
			cancButt.setHorizontalTextPosition(AbstractButton.CENTER);
			cancButt.setFont(new Font("Tahoma", Font.BOLD, x/90));
			cancButt.setBounds(9*x/11, 22*y/24, 6*x/45, 2*y/30);
			return cancButt;
		}
		
		
		private JButton getHeshbonPrintButton()
		{
			Icon heshbonIcon = new ImageIcon("print-icon.png");
			Image img = ((ImageIcon) heshbonIcon).getImage();
			Image newimg = img.getScaledInstance(40, 40,java.awt.Image.SCALE_SMOOTH);
			heshbonIcon = new ImageIcon(newimg);
			JButton heshbonButt=new JButton("הדפסת חשבון",heshbonIcon);
			heshbonButt.setBackground(new Color(200,250,230));
			heshbonButt.setVerticalTextPosition(AbstractButton.BOTTOM);
			heshbonButt.setHorizontalTextPosition(AbstractButton.CENTER);
			heshbonButt.setFont(new Font("Tahoma", Font.BOLD, x/90));
			heshbonButt.setBounds(9*x/11, 15*y/30, 6*x/45, 2*y/24);
			
			heshbonButt.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) 
				{
					Date date = new Date();
					 DateFormat df = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
					 String   data = df.format(date);
					
					 MenuesForPrintForFullBon menues = new MenuesForPrintForFullBon();
					 Vector<MenuesForPrintForFullBon> menuesForPrint = new  Vector<MenuesForPrintForFullBon>();
					 FullBon bonForPrint = new FullBon();
					 ArrayList<FullBon> dataList = new ArrayList<FullBon>();
					 
					 Vector<String> row = new Vector<String>();
					 row.add("rice");
					 row.add("potatos");
					 menues.setMid("3");
					 menues.setmName("טעימות");
					 menues.setRecipesForChoose(row);
					 menuesForPrint.add(menues);
					 
					 bonForPrint.setTid("5");
					 bonForPrint.setName("אנדריי");
					 bonForPrint.setDate(data);
				     bonForPrint.setOrderId("3");
				//	 bonForPrint.setComment("KRUTO");
					 
					// bonForPrint.setMenues(menuesForPrint);
					 dataList.add(bonForPrint);
					 JRBeanCollectionDataSource reportData = new JRBeanCollectionDataSource(
								dataList);
						JasperPrint print;
						try {
							print = JasperFillManager
									.fillReport(
											"Reports/Orders/test.jasper",
											null, reportData);
							JasperViewer.viewReport(print);
							
						} catch (JRException e1) {
							// TODO Auto-generated catch block
							e1.printStackTrace();
						}					
					
					

				}
			});
			return heshbonButt;
		}
		

		
		
		
		private JButton getPaymentButton()
		{
			Icon paymentIcon = new ImageIcon("payment-icon.png");
			Image img = ((ImageIcon) paymentIcon).getImage();
			Image newimg = img.getScaledInstance(40, 40,java.awt.Image.SCALE_SMOOTH);
			paymentIcon = new ImageIcon(newimg);
			JButton paymentButt=new JButton("תשלום",paymentIcon);
			paymentButt.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) 
				{
					mainMenu.getContentPane().remove(((BorderLayout) mainMenu.getContentPane().getLayout()).getLayoutComponent(BorderLayout.CENTER));
					mainMenu.getContentPane().add( new PfPointOfSale(mainMenu,bones,metaDataOrder),BorderLayout.CENTER);
					
					

				}
			});
			paymentButt.setBackground(new Color(200,250,230)); 
			paymentButt.setVerticalTextPosition(AbstractButton.BOTTOM);
			paymentButt.setHorizontalTextPosition(AbstractButton.CENTER);
			paymentButt.setFont(new Font("Tahoma", Font.BOLD, x/90));
			paymentButt.setBounds(9*x/11, 15*y/24, 6*x/45, 2*y/24);
			
			paymentButt.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) 
				{
					
					
					

				}
			});
			return paymentButt;
		}
		
		
		
		private JScrollPane getOrderList()
		{
			int flag=0;
			ForBonList bonList = new ForBonList();
			Vector<ForBonList> vectorBonList = new Vector<ForBonList>();
			Vector<ChkObj> itms=new Vector<ChkObj>();
		
			
			
			for(int i=0;i<bones.size();i++)
			{
				
				flag=0;
				for(int j=0;j<vectorBonList.size();j++)
				{
					if(Integer.parseInt(bones.get(i).getMid())==vectorBonList.get(j).getMenu().getMid())         //esli est uje takoe menu v liste 
					{
						flag=1;                                                                                     // pomechaem chto nashlos sovpadenie
						if(bones.get(i).getType().equals("business"))                                              // esli eto business menu 
						{
							vectorBonList.get(j).setQuantity((vectorBonList.get(j).getQuantity())+1);             //uvelichivaem kolichestvo
						//!!!!!!!!!!!!  sdes nujno dobavit proverku esli li v etom menu recipe dlia vibora
							RecipeForFire notConstantrecipe=new RecipeForFire();
							notConstantrecipe.setName(bones.get(i).getRname());
							notConstantrecipe.setRid(Integer.parseInt(bones.get(i).getRid()));
							notConstantrecipe.setExtra(bones.get(i).getExtra());
							notConstantrecipe.setSouce(bones.get(i).getSouce());
							boolean fired=false;
							boolean submitted=false;
							if(bones.get(i).getIsFired()==1) fired=true;
							if(bones.get(i).getIsSubmitted()==1) submitted=true;
							notConstantrecipe.setFired(fired);
							notConstantrecipe.setSubmitted(submitted);
							///       zapolnaem fired i submitted v recipe dlia vibora  //////////						
							
							String comments1=null;
							if(!bones.get(i).getComments().isEmpty())
								comments1=bones.get(i).getComments();
							else
								comments1="empty";
							
							for(int a=0;a<vectorFireForManegeTableOrder.size();a++)
							{
								FireForManageTableOrder fire=vectorFireForManegeTableOrder.get(a);
								
								String comments2=null;
								if(fire.getComments()!=null && !fire.getComments().isEmpty() )
									 comments2=fire.getComments();
								else
									 comments2="empty";
								
								//esli rid, mid, souceRid, extraRid i comments ravni 
								if(fire.getRid()==notConstantrecipe.getRid() && fire.getMid()==Integer.parseInt(bones.get(i).getMid())  && fire.getExtra().getId().equals(bones.get(i).getExtra().getId()) && fire.getSouce().getId().equals(bones.get(i).getSouce().getId()) && comments1.equals(comments2)  )   
								{
									notConstantrecipe.setFired(fire.isFired());
									notConstantrecipe.setSubmitted(fire.isSubmitted());
									vectorFireForManegeTableOrder.remove(a);
									break;
									
								}
							}
							vectorBonList.get(j).getNotConstantRecipes().add(notConstantrecipe);          // dobavlaem  bludo dlia vibora v Vector<Recipe> v kotorom est tolko bluda dlia vibora 
						}
						if(bones.get(i).getType().equals("simple"))                                    // esli eto simple menu 
						{
							RecipeForFire notConstantRecipeForFire=new RecipeForFire();
							notConstantRecipeForFire.setName(bones.get(i).getRname());
							notConstantRecipeForFire.setRid(Integer.parseInt(bones.get(i).getRid()));
							notConstantRecipeForFire.setExtra(bones.get(i).getExtra());
							notConstantRecipeForFire.setSouce(bones.get(i).getSouce());
							notConstantRecipeForFire.setActionLevel(bones.get(i).getActionLevel());
							notConstantRecipeForFire.setComments(bones.get(i).getComments());
							notConstantRecipeForFire.setPrice(bones.get(i).getPrice());
							boolean fired=false;
							boolean submitted=false;
							if(bones.get(i).getIsFired()==1) fired=true;
							if(bones.get(i).getIsSubmitted()==1) submitted=true;
							String comments1=null;
							if(!bones.get(i).getComments().isEmpty())
								comments1=bones.get(i).getComments();
							else
								comments1="empty";
							///       zapolnaem fired i submitted v recipe dlia vibora  //////////
							for(int a=0;a<vectorFireForManegeTableOrder.size();a++)
							{
								FireForManageTableOrder fire=vectorFireForManegeTableOrder.get(a);
								
								
								String comments2=null;
								if(fire.getComments()!=null && !fire.getComments().isEmpty())
									 comments2=fire.getComments();
								else
									 comments2="empty";								
								
								
								if(fire.getRid()==notConstantRecipeForFire.getRid() && fire.getMid()==Integer.parseInt(bones.get(i).getMid())  && fire.getExtra().getId().equals(bones.get(i).getExtra().getId()) && fire.getSouce().getId().equals(bones.get(i).getSouce().getId()) && comments1.equals(comments2))   
								{
									notConstantRecipeForFire.setFired(fire.isFired());
									notConstantRecipeForFire.setSubmitted(fire.isSubmitted());
									vectorFireForManegeTableOrder.remove(a);
									break;									
								}
							}
							
							vectorBonList.get(j).getNotConstantRecipes().add(notConstantRecipeForFire);

														
						}
					}
				}
				
				
				
				
				
				
				
				
				
				
				
				
				
				if(flag==0)                                                                            // esli ne nashli sovpadenie ,znachit v liste net takogo menu i nujno ego dobavit 
				{
					if(bones.get(i).getType().equals("business"))
					{
						ForBonList forBonList=new ForBonList();
						MenuForFire menu=new MenuForFire();
						menu.setMid(Integer.parseInt(bones.get(i).getMid()));
						menu.setName(bones.get(i).getMname());
						menu.setPrice(bones.get(i).getPrice());
						menu.setType(bones.get(i).getType());
						forBonList.setMenu(menu);
						forBonList.setQuantity(1);
						
						// zapolnaem recept, kotoriy vibiraetsa klientom
						RecipeForFire notConstantRecipeForFire=new RecipeForFire();
						notConstantRecipeForFire.setName(bones.get(i).getRname());
						notConstantRecipeForFire.setRid(Integer.parseInt(bones.get(i).getRid()));
						notConstantRecipeForFire.setExtra(bones.get(i).getExtra());
						notConstantRecipeForFire.setSouce(bones.get(i).getSouce());
						notConstantRecipeForFire.setActionLevel(bones.get(i).getActionLevel());
						notConstantRecipeForFire.setComments(bones.get(i).getComments());
						notConstantRecipeForFire.setFired(false);
						notConstantRecipeForFire.setSubmitted(false);
						String comments1=null;
						if(!bones.get(i).getComments().isEmpty())
							comments1=bones.get(i).getComments();
						else
							comments1="empty";
						///       zapolnaem fired i submitted v recipe dlia vibora  //////////
						for(int a=0;a<vectorFireForManegeTableOrder.size();a++)
						{
							FireForManageTableOrder fire=vectorFireForManegeTableOrder.get(a);
							String comments2=null;
							if(fire.getComments()!=null && !fire.getComments().isEmpty() )
								 comments2=fire.getComments();
							else
								 comments2="empty";
							if(fire.getRid()==notConstantRecipeForFire.getRid() && fire.getMid()==Integer.parseInt(bones.get(i).getMid())  && fire.getExtra().getId().equals(bones.get(i).getExtra().getId()) && fire.getSouce().getId().equals(bones.get(i).getSouce().getId()) )   
							{
								notConstantRecipeForFire.setFired(fire.isFired());
								notConstantRecipeForFire.setSubmitted(fire.isSubmitted());
								vectorFireForManegeTableOrder.remove(a);
								break;									
							}
						}
						forBonList.getNotConstantRecipes().add(notConstantRecipeForFire);
						
						
						
						//zapolnaem postoyannie rezepti etogo menu 
						for(int k=0;k<menues.size();k++)
						{
							if(bones.get(i).getMid().equals(menues.get(k).getId()))
							{
								Vector<Recipe> recipesOfMenu=menues.get(k).getRecipes();
								for(int a=0;a<recipesOfMenu.size();a++)
								{
									
									if(recipesOfMenu.get(a).getIsSelectable()==0)
									{
										RecipeForFire constantRecipeForFire=new RecipeForFire();
										constantRecipeForFire.setRid(Integer.parseInt(recipesOfMenu.get(a).getId()));
										constantRecipeForFire.setName(recipesOfMenu.get(a).getName());
										constantRecipeForFire.setFired(false);
										constantRecipeForFire.setSubmitted(false);
										forBonList.getConstantRecipes().add(constantRecipeForFire);
										String comments1_1=null;
										if(!bones.get(i).getComments().isEmpty())
											comments1_1=bones.get(i).getComments();
										else
											comments1_1="empty";
										///       zapolnaem fired i submitted v recipe dlia vibora  //////////
										for(int b=0;b<vectorFireForManegeTableOrder.size();b++)
										{
											FireForManageTableOrder fire=vectorFireForManegeTableOrder.get(b);
											String comments2=null;
											if(fire.getComments()!=null && !fire.getComments().isEmpty()  )
											{
												 comments2=fire.getComments();
											}
											else
											{
												 comments2="empty";
											}
											if(fire.getRid()==constantRecipeForFire.getRid() && fire.getMid()==Integer.parseInt(bones.get(i).getMid())  && fire.getExtra().getId().equals(bones.get(i).getExtra().getId()) && fire.getSouce().getId().equals(bones.get(i).getSouce().getId()) )   
											{
												constantRecipeForFire.setFired(fire.isFired());
												constantRecipeForFire.setSubmitted(fire.isSubmitted());
												vectorFireForManegeTableOrder.remove(b);
												break;									
											}
										}
									}
								}
								
							}
							break;
						}
						vectorBonList.add(forBonList);
					}
					
					
					
					if(bones.get(i).getType().equals("simple"))
					{
						ForBonList forBonList=new ForBonList();
						MenuForFire menu =new MenuForFire();
						menu.setMid(Integer.parseInt(bones.get(i).getMid()));        
						menu.setName(bones.get(i).getMname());
						menu.setType(bones.get(i).getType());
						forBonList.setQuantity(1);
						forBonList.setMenu(menu);
						
						RecipeForFire notConstantRecipeForFire=new RecipeForFire();
						notConstantRecipeForFire.setName(bones.get(i).getRname());
						notConstantRecipeForFire.setRid(Integer.parseInt(bones.get(i).getRid())); 
						notConstantRecipeForFire.setExtra(bones.get(i).getExtra());
						notConstantRecipeForFire.setSouce(bones.get(i).getSouce());
						notConstantRecipeForFire.setActionLevel(bones.get(i).getActionLevel());
						notConstantRecipeForFire.setComments(bones.get(i).getComments());
						notConstantRecipeForFire.setPrice(bones.get(i).getPrice());
						notConstantRecipeForFire.setFired(false);
						notConstantRecipeForFire.setSubmitted(false);
						String comments1=null;
						if(!bones.get(i).getComments().isEmpty())
							comments1=bones.get(i).getComments();
						else
							comments1="empty";
						///       zapolnaem fired i submitted v recipe dlia vibora  //////////
						for(int b=0;b<vectorFireForManegeTableOrder.size();b++)
						{
							FireForManageTableOrder fire=vectorFireForManegeTableOrder.get(b);
							String comments2=null;
							if(fire.getComments()!=null && !fire.getComments().isEmpty() )
								 comments2=fire.getComments();
							else
								 comments2="empty";
							
							
							
							if(fire.getRid()==notConstantRecipeForFire.getRid() && fire.getMid()==Integer.parseInt(bones.get(i).getMid())  && fire.getExtra().getId().equals(bones.get(i).getExtra().getId()) && fire.getSouce().getId().equals(bones.get(i).getSouce().getId()) )   
							{
								notConstantRecipeForFire.setFired(fire.isFired());
								notConstantRecipeForFire.setSubmitted(fire.isSubmitted());
								vectorFireForManegeTableOrder.remove(b);
								break;									
							}
						}
						forBonList.getNotConstantRecipes().add(notConstantRecipeForFire);
						vectorBonList.add(forBonList);
					}
					
				}
				
			}
			
			
			
			for(int count=0;count<vectorBonList.size();count++)
			{

				ForBonList forBonList=vectorBonList.get(count);
				if(forBonList.getMenu().getType().equals("business"))
				{
			    //dobavlaem nazvanie menu 	
					String price=vectorBonList.get(count).getMenu().getPrice();
					int quantity=vectorBonList.get(count).getQuantity();
					int totalPriceInt=Integer.parseInt(price)*quantity;					
					String quan=Integer.toString(quantity);					
					String longSpace="     ";
					String shortSpace=" ";
					String totalPrice=Integer.toString(totalPriceInt)+" "+"ש\"ח";
					String nameOfMenu=vectorBonList.get(count).getMenu().getName();

					String menuTxt=nameOfMenu+"*"+quan+longSpace+totalPrice;
				
					itms.add(new ChkObj(menuTxt, false,"string"));
					
				//dobavlaem postoyannie rezepti	v list
				Vector<RecipeForFire> constantRecipesVector= forBonList.getConstantRecipes();
				for(int x=0; x<constantRecipesVector.size();x++)
				{
					RecipeForFire constantRecipeForFire=constantRecipesVector.get(x);
					String nameOfRecipe=constantRecipeForFire.getName();
					String recipeTxt=nameOfRecipe+shortSpace+"*"+quan;
					itms.add(new ChkObj(recipeTxt,"checkBox", constantRecipeForFire.isFired(),constantRecipeForFire.isSubmitted(),constantRecipeForFire,forBonList,quantity));
					
				}  //for(int x=0; x<constantRecipesVector.size();x++)
				
				
				//dobavlaem rezepti vibrannie klientom
				Vector<RecipeForFire> notConstantRecipesVector= forBonList.getNotConstantRecipes();
				for(int x=0; x<notConstantRecipesVector.size();x++)
				{
					RecipeForFire notConstantRecipeForFire=notConstantRecipesVector.get(x);
					String nameOfRecipe=notConstantRecipeForFire.getName();
					String recipeTxt=nameOfRecipe;
					String recipeActionLevel=null;
					String recipeExtra=null;
					String recipeSouce=null;
					String recipeComments=null;
					
					if(notConstantRecipeForFire.getActionLevel()!=null)
						//recipeTxt=recipeTxt+"--"+"מ.ע:"+notConstantRecipeForFire.getActionLevel();
						recipeActionLevel="מידת עשייה: "+notConstantRecipeForFire.getActionLevel();
					
					if(notConstantRecipeForFire.getExtra().getName()!=null)
						//recipeTxt=recipeTxt+"--"+"ת:"+notConstantRecipeForFire.getExtra().getName();
						recipeExtra="תוספת: "+notConstantRecipeForFire.getExtra().getName();
					if(notConstantRecipeForFire.getSouce().getName()!=null)
						//recipeTxt=recipeTxt+"--"+"ס:"+notConstantRecipeForFire.getSouce().getName();
						recipeSouce="רוטב: "+notConstantRecipeForFire.getSouce().getName();
					
					if(notConstantRecipeForFire.getComments()!=null && !notConstantRecipeForFire.getComments().isEmpty() )
						//recipeTxt=recipeTxt+"--"+"הערות:"+notConstantRecipeForFire.getComments();
						recipeComments="הערות: "+notConstantRecipeForFire.getComments();
					
					itms.add(new ChkObj(nameOfRecipe,recipeActionLevel,recipeExtra,recipeSouce,recipeComments,"checkBox", notConstantRecipeForFire.isFired(),notConstantRecipeForFire.isSubmitted(),notConstantRecipeForFire,forBonList,1));
					
				}  //for(int x=0; x<notConstantRecipesVector.size();x++)
				
				}  //if(forBonList.getMenu().getType().equals("business"));
				
				
				
				//esli eto simple menu 
					if(forBonList.getMenu().getType().equals("simple"))
					{
						//dobavlaem nazvanie menu 
						
						
						//dobavlaem rezepti vibrannie klientom
						Vector<RecipeForFire> notConstantRecipesVector= forBonList.getNotConstantRecipes();
						
						//schitaem total price
						int totalPrice=0;
						for(int q=0;q<notConstantRecipesVector.size();q++)
						{
							RecipeForFire notConstantRecipeForFire=notConstantRecipesVector.get(q);
							totalPrice=totalPrice+Integer.parseInt(notConstantRecipeForFire.getPrice());
						}
						
						
						String nameOfMenu=vectorBonList.get(count).getMenu().getName();
						String menuTxt=nameOfMenu+"          "+Integer.toString(totalPrice)+" "+"ש\"ח";
						itms.add(new ChkObj(menuTxt, false,"string"));
						
						for(int x=0; x<notConstantRecipesVector.size();x++)
						{
							
							RecipeForFire notConstantRecipeForFire=notConstantRecipesVector.get(x);
							
						
							
							String nameOfRecipe=notConstantRecipeForFire.getName();
							String recipeTxt=nameOfRecipe;
							String recipeActionLevel=null;
							String recipeExtra=null;
							String recipeSouce=null;
							String recipeComments=null;
							
							if(notConstantRecipeForFire.getActionLevel()!=null)
								//recipeTxt=recipeTxt+"--"+"מ.ע:"+notConstantRecipeForFire.getActionLevel();
								recipeActionLevel="מידת עשייה: "+notConstantRecipeForFire.getActionLevel();
							
							if(notConstantRecipeForFire.getExtra().getName()!=null)
								//recipeTxt=recipeTxt+"--"+"ת:"+notConstantRecipeForFire.getExtra().getName();
								recipeExtra="תוספת: "+notConstantRecipeForFire.getExtra().getName();
							if(notConstantRecipeForFire.getSouce().getName()!=null)
								//recipeTxt=recipeTxt+"--"+"ס:"+notConstantRecipeForFire.getSouce().getName();
								recipeSouce="רוטב: "+notConstantRecipeForFire.getSouce().getName();
							
							if(notConstantRecipeForFire.getComments()!=null && !notConstantRecipeForFire.getComments().isEmpty() )
								//recipeTxt=recipeTxt+"--"+"הערות:"+notConstantRecipeForFire.getComments();
								recipeComments="הערות: "+notConstantRecipeForFire.getComments();
							
							
							
							recipeTxt=recipeTxt+"---------"+notConstantRecipeForFire.getPrice()+" "+"ש\"ח";
							itms.add(new ChkObj(recipeTxt,recipeActionLevel,recipeExtra,recipeSouce,recipeComments,"checkBox", notConstantRecipeForFire.isFired(),notConstantRecipeForFire.isSubmitted(),notConstantRecipeForFire,forBonList,1));
							
						}  //for(int x=0; x<notConstantRecipesVector.size();x++)
						
					}
				
			
			}
			
			
			

			 orderList = new JList(itms);
			 
			 orderList.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
			 
			 orderList.setBorder(new EmptyBorder(10,10,10, 10));
			// orderList.setFixedCellHeight(70);
			 orderList.setAutoscrolls(true);
		//	 orderList.setBorder(new LineBorder(Color.darkGray, 1));
			 orderList.setBackground(new Color(255, 255, 224));
			JScrollPane orderListScrollPane=new JScrollPane(orderList);
			orderListScrollPane.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), " \u05D1\u05D5\u05DF ", TitledBorder.CENTER, TitledBorder.TOP, new Font("Tahoma", Font.ITALIC, 16), new Color(0, 0, 139)));
			orderList.setCellRenderer(new ChkRender());
			orderListScrollPane.setBounds(10*x/34,10*y/190, 10*x/32, 10*y/15);		
			
			
			
			orderList.addMouseListener(new MouseAdapter() {
			      public void mouseReleased(MouseEvent e) {
			        // create PropertySetter, which defines the object
			        // (list) and property ("selectedIndex") to be changed
			        // and the values that it will animate from and to
			    	  mousePressedFlag=0;
			       // PropertySetter ps = new PropertySetter(orderList,"selectedIndex", orderList.getSelectedIndex(),orderList.getSelectedIndex() + 10);
			       // PropertySetter ps = new PropertySetter(orderList,"selectedIndex", orderList.getLastVisibleIndex(),orderList.getLastVisibleIndex()+ 1);

			        // Create Animator, which will animate ps
			        // for 1000 milliseconds
			        //Animator a = new Animator(1000, ps);
			        // start the timer
			       // a.start();
			      }});
			
			orderList.addMouseListener(new MouseAdapter(){
	            public void  mouseClicked(MouseEvent e) { 
	            	mousePressedFlag=1;
	            	//e.notifyAll();
	                ChkObj tmp = null;
	                if (e.getClickCount() == 1) {
	                    tmp = ((ChkObj) orderList.getSelectedValue());
	                    tmp.flagFired = !tmp.flagFired;
	                    orderList.repaint();
	            }}});
			
			orderList.addMouseListener(new MouseAdapter(){
	            public void  mousePressed(MouseEvent e) { 
	            	mousePressedFlag=1;
	            
	              
	            }});
			
			orderList.addMouseListener(new MouseAdapter(){
	            public void  mouseEntered(MouseEvent e) { 
	            	mousePressedFlag=1;
	            
	              
	            }});
			
		//	orderList.addMouseMotionListener(this);                 // listener na dvijenie mishki 
			//addMouseMotionListener(this);
			
			return orderListScrollPane;
		}
		
		private JButton getDownButton()
		{
			Icon downIcon = new ImageIcon("down_icon.png");
			Image img = ((ImageIcon) downIcon).getImage();
			Image newimg = img.getScaledInstance(x/30, x/30,java.awt.Image.SCALE_SMOOTH);
			downIcon = new ImageIcon(newimg);
			JButton downButton=new JButton(downIcon);
			downButton.setVerticalTextPosition(AbstractButton.BOTTOM);
			downButton.setHorizontalTextPosition(AbstractButton.CENTER);
			downButton.setFont(new Font("Tahoma", Font.BOLD, x/90));
			downButton.setBounds(63*x/100, 11*y/23, 5*x/100, 2*y/24);
			downButton.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) 
				{
					orderList.ensureIndexIsVisible(orderList.getLastVisibleIndex()+1);
					
					 //PropertySetter ps = new PropertySetter(orderList,
					//  "selectedIndex",orderList.getLastVisibleIndex(),orderList.getLastVisibleIndex()+10);
					        // Create Animator, which will animate ps
					        // for 1000 milliseconds
					        //Animator a = new Animator(1000, ps);
					        // start the timer
					       // a.start();					
				}
			});
			
			
			
			
			return downButton;
		}

		
		
		private JButton getDownToEndButton()
		{
			Icon downIcon = new ImageIcon("downToEnd_icon.png");
			Image img = ((ImageIcon) downIcon).getImage();
			Image newimg = img.getScaledInstance(x/30, x/30,java.awt.Image.SCALE_SMOOTH);
			downIcon = new ImageIcon(newimg);
			JButton downButton=new JButton(downIcon);
			downButton.setVerticalTextPosition(AbstractButton.BOTTOM);
			downButton.setHorizontalTextPosition(AbstractButton.CENTER);
			downButton.setFont(new Font("Tahoma", Font.BOLD, x/90));
			downButton.setBounds(63*x/100, 13*y/23, 5*x/100, 2*y/24);
			downButton.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) 
				{
					orderList.ensureIndexIsVisible(orderList.getModel().getSize()-1);
					
								
				}
			});
	
			
			return downButton;
		}

		private JButton getUpToEndButton()
		{
			Icon upIcon = new ImageIcon("upToEnd_icon.png");
			Image img = ((ImageIcon) upIcon).getImage();
			Image newimg = img.getScaledInstance(x/30, x/30,java.awt.Image.SCALE_SMOOTH);
			upIcon = new ImageIcon(newimg);
			JButton upButton=new JButton(upIcon);
			upButton.setVerticalTextPosition(AbstractButton.BOTTOM);
			upButton.setHorizontalTextPosition(AbstractButton.CENTER);
			upButton.setFont(new Font("Tahoma", Font.BOLD, x/90));
			upButton.setBounds(63*x/100, 14*y/70, 5*x/100, 2*y/24);
			upButton.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) 
				{
					orderList.ensureIndexIsVisible(0);
									
				}
			});
			
			return upButton;
		}
		
		
		private JButton getUpButton()
		{
			Icon upIcon = new ImageIcon("up_icon.png");
			Image img = ((ImageIcon) upIcon).getImage();
			Image newimg = img.getScaledInstance(x/30, x/30,java.awt.Image.SCALE_SMOOTH);
			upIcon = new ImageIcon(newimg);
			JButton upButton=new JButton(upIcon);
			upButton.setVerticalTextPosition(AbstractButton.BOTTOM);
			upButton.setHorizontalTextPosition(AbstractButton.CENTER);
			upButton.setFont(new Font("Tahoma", Font.BOLD, x/90));
			upButton.setBounds(63*x/100, 20*y/70, 5*x/100, 2*y/24);
			
			upButton.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) 
				{
					orderList.ensureIndexIsVisible(orderList.getFirstVisibleIndex()-1);
									
				}
			});
			
			return upButton;
		}
		
		
		


		@Override
		public void mouseDragged(MouseEvent arg0) {
			
		}





		@Override
		public void mouseMoved(MouseEvent arg0) {
			// TODO Auto-generated method stub
			if(firstPoint==-1 ) firstPoint=arg0.getYOnScreen();
			
			secondPoint=arg0.getYOnScreen();
			if(secondPoint-firstPoint>10)               //move down
			{
		    orderList.ensureIndexIsVisible(orderList.getLastVisibleIndex()+1);
			firstPoint=secondPoint;
			}
			
			if(secondPoint<firstPoint)           //move up
			{
				
				firstPoint=secondPoint;
			}
		}

		//nemnogo zaputanno , no ideya takaya :
		//	1.beretsa vector bones i proveraem ego soderjimoe
		//	2.ischem v vector<ForBonList> est li uje tam mid proveraemogo menu
		//	3.esli est to smotrim na type menu 
		//	4.esli type==business : uvelichevimaem quantity na 1 , zapisivaem v Vector<String> mana le bhira
		//	5 esli type==simple   : sozdaem RecipeOfSimpleMenu , zapolnaem ego polia i dobavlaem v Vector<RecipeOfSimpleMenu>
		//	6 esli net takogo mid sozdaem noviy ForBonList, zapolnaem neobhodimie polia i dobalaem ego v Vector<ForBonList>
		
}
